Skip to content

feat: add working-directory input#21

Merged
fengmk2 merged 9 commits intovoidzero-dev:mainfrom
hyoban:4-23-cwd
Mar 23, 2026
Merged

feat: add working-directory input#21
fengmk2 merged 9 commits intovoidzero-dev:mainfrom
hyoban:4-23-cwd

Conversation

@hyoban
Copy link
Copy Markdown
Contributor

@hyoban hyoban commented Mar 23, 2026

Follow #20

I found that the version printed by vite+ is also incorrect. I'm thinking that adding a working-directory might be better, which could also simplify the configuration.

It looks like the working-directory from the GitHub action does not work with uses. https://github.com/orgs/community/discussions/25742

Feel free to close this PR if you do not want to introduce another "cwd" input.

@hyoban hyoban marked this pull request as ready for review March 23, 2026 14:17
Copilot AI review requested due to automatic review settings March 23, 2026 14:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a working-directory input to the GitHub Action so relative paths (lockfile detection, node-version-file, and default vp install execution) can be scoped to a project subdirectory—addressing cases where the workflow step working-directory doesn’t apply to uses: actions.

Changes:

  • Introduce working-directory input (action.yml + inputs/types) and thread it through install/cache/version resolution flows.
  • Refactor path handling utilities to support configurable base directories (resolvePath, getConfiguredProjectDir, getInstallCwd, detectLockFile(searchDir)).
  • Update docs/tests to cover working-directory behavior and correct version printing by running vp --version in the configured project directory.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils.ts Adds path/base-dir helpers and project-dir resolution used by install/cache/version logic.
src/utils.test.ts Adds/adjusts unit tests for new path and working-directory behaviors.
src/types.ts Extends Inputs with workingDirectory.
src/run-install.ts Runs vp install in a cwd derived from working-directory + optional per-step override.
src/node-version-file.ts Resolves version files relative to an explicit base directory (projectDir).
src/node-version-file.test.ts Adds a unit test for base-directory path resolution.
src/inputs.ts Parses the new working-directory input.
src/inputs.test.ts Updates input parsing tests for the new field.
src/index.ts Uses configured project dir for node-version file resolution and vp --version output.
src/cache-restore.ts Runs lockfile detection relative to configured project dir; derives cache cwd from lockfile dir.
action.yml Declares the new working-directory input.
README.md Documents working-directory usage and semantics.
Comments suppressed due to low confidence (1)

src/inputs.test.ts:34

  • This assertion expects only a subset of the Inputs object, but getInputs() currently includes registryUrl and scope fields as well. As written, toEqual will fail due to the extra keys; either include registryUrl/scope (as undefined) in the expected object, or switch to an assertion that matches only the fields you care about (e.g., toMatchObject).
    expect(inputs).toEqual({
      version: "latest",
      nodeVersion: undefined,
      nodeVersionFile: undefined,
      workingDirectory: undefined,
      runInstall: [],
      cache: false,
      cacheDependencyPath: undefined,
    });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils.ts
Comment thread src/utils.ts Outdated
Copilot AI review requested due to automatic review settings March 23, 2026 14:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/run-install.ts Outdated
Comment thread src/utils.test.ts
Comment thread action.yml
Copilot AI review requested due to automatic review settings March 23, 2026 14:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyoban Thanks again. I like the working-directory input, it's better one and we should support it too.

@fengmk2 fengmk2 merged commit 20553a7 into voidzero-dev:main Mar 23, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants